package com.dykj.fireFighting.server.base.maintenance.mapper;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dykj.fireFighting.api.base.devHisResult.vo.ResultVo;
import com.dykj.fireFighting.api.base.maintenance.dto.UrgentMaintenanceDto;
import com.dykj.fireFighting.api.base.maintenance.entity.UrgentMaintenance;
import com.dykj.fireFighting.api.base.maintenance.vo.MaintenanceEvaluationVo;
import com.dykj.fireFighting.api.base.maintenance.vo.MaintenanceStatisticsVo;
import com.dykj.fireFighting.api.base.maintenance.vo.UrgentMaintenanceStatisticsVo;
import com.dykj.fireFighting.api.base.maintenance.vo.UrgentMaintenanceVo;
import com.dykj.fireFighting.common.core.mapper.SuperMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 紧急维保记录
 * @Author JacksonTu
 * @Date 2021-07-28 08:38:40
 */
public interface UrgentMaintenanceMapper extends SuperMapper<UrgentMaintenance> {
    UrgentMaintenanceStatisticsVo getStatistics(@Param("wbId") String wbId);

    /**
     * 紧急维保记录-分页列表查询
     *
     * @param page
     * @param params
     * @return
     */
    IPage queryUrgentMaintenanceList(Page page, @Param("params") HashMap<String, Object> params);

    /**
     * 获取紧急维保维修记录信息
     *
     * @param id
     * @return
     */
    UrgentMaintenanceVo getInfoById(@Param("id") String id);

    /**
     * 维保评价列表
     *
     * @param page
     * @param params
     * @return
     */
    IPage queryEvaluationList(Page page, @Param("params") HashMap<String, Object> params);

    /**
     * 维保数据统计
     *
     * @param params
     * @return
     */
    List<MaintenanceStatisticsVo> getMaintenanceStatistics(@Param("params") HashMap<String, Object> params);

    /**
     * 今日上传维保信息的社会单位数量
     *
     * @param params
     * @return
     */
    int getUnitNumByWbId(@Param("params") HashMap<String, Object> params);

    /**
     * 待处理/紧急维保  统计
     *
     * @param params
     * @return
     */
    int getNotFinishedMaintenanceStatistics(@Param("params") HashMap<String, Object> params);


    /**
     * 紧急维保记录分页列表
     *
     * @param page
     * @param params
     * @return
     */
    IPage<UrgentMaintenanceVo> queryUrgentList(IPage<UrgentMaintenanceDto> page, @Param("params") Map<String, Object> params);


    /**
     * @param id
     * @return
     */
    UrgentMaintenanceVo getUrgentMaintenanceInfoById(String id);

    /**
     * 维保服务机构的当月评价得分
     *
     * @param params
     * @return
     */
    List<MaintenanceEvaluationVo> queryMaintenanceEvaluationList(@Param("params") Map<String, Object> params);

    /**
     * 获取有效的整改数量
     *
     * @param start
     * @param end
     * @param socUnitId
     * @return
     */
    int getEffectiveUrgentNum(@Param("start") String start, @Param("end") String end, @Param("socUnitId") String socUnitId);

    /**
     * 时间周期内所有整改的数量
     *
     * @param start
     * @param end
     * @param socUnitId
     * @return
     */
    int getUrgentNum(@Param("start") String start, @Param("end") String end, @Param("socUnitId") String socUnitId);


    int getCenterNum(@Param("ids") List<String> ids, @Param("beginTime") String beginTime, @Param("endTime") String endTime);

    int getUnitNum(@Param("id") String id,@Param("beginTime") String beginTime,@Param("endTime") String endTime);

    @Update("update urgent_maintenance set arrive_time=#{arriveTime} where id=#{id}")
    int updateArriveTime(@Param("id") String id,@Param("arriveTime") String arriveTime);

    /**
     * 紧急维保 维保机构当月评价得分详情
     *
     * @param params
     * @return
     */
    List<UrgentMaintenanceVo> queryUrgentMaintenanceEvaluationInfoList(@Param("params") Map<String, Object> params);

    List<ResultVo> getRankByDate(@Param("beginTime") String beginTime,@Param("endTime") String endTime,@Param("ids") List<String> ids);

    int getAllUnitByDay(@Param("ids") List<String> ids,@Param("begin") String begin,@Param("end") String end);

    List<ResultVo> getUnitByDay(@Param("beginTime") String beginTime,@Param("endTime") String endTime, @Param("unitId") String unitId);

    List<ResultVo> getMonthByDate(@Param("beginTime") String beginTime,@Param("endTime") String endTime,@Param("unitId") String unitId);

    List<ResultVo> getQuarterByDate(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("unitId") String unitId);

    List<ResultVo> getYearByDate(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("unitId") String unitId);

    List<ResultVo> getAllDay(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);

    List<ResultVo> getAllMonth(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);

    List<ResultVo> getAllQuarter(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);

    List<ResultVo> getAllYear(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);

    List<ResultVo> getTrendEcharts(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
}
